﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="d" uri="/WEB-INF/resource.tld" %>

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />
<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  
</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>
  
  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content">

    <div class="panel panel-default x-panel x-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/online-rounds">课程管理</a></li>
          <li class="active">动作库管理</li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">

          <div class="x-breadcrumb-wrapper">
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire" title=""></i>&nbsp;&nbsp;<span>动作库管理&nbsp;-&nbsp;动作库</span></h2>
            </div>
            
            <div class="x-breadcrumb-wrapper top-margin-20" style="position: relative;">
              <ul class="nav nav-pills x-breadcrumb-nav">
                <li class="pull-left active"><a href="javascript:void(0);">人马君动作库</a></li>
              </ul>
            </div>
            
            
            <div class="x-breadcrumb-wrapper clearfix" style="position: relative; margin-top: 15px;">
              <form class="form-horizontal pull-left" method="GET" action="${ctx.host}/movements" data-validate="true">
                <input type="hidden" name="filter" value="true" >
                <div class="pull-left">
                  <div class="col-xs-4">
                    <input type="text" class="form-control" name="name" value="${param.name}" placeholder="请输入名称"/>
                  </div>
                  <div class="col-xs-4">
                    <select name="categoryId" class="select2 form-control">
                      <option></option>
                      <c:forEach var="category" items="${persist.categories}">
                        <c:if test="${not category.disabled}">
                          <option value="${category.id}" ${category.id == param.categoryId ? 'selected' : ''}>${category.name}</option>
                        </c:if>
                      </c:forEach>
                    </select>
                  </div>
                  <div class="col-xs-4">
                    <select name="equipmentId" class="select2 form-control">
                      <option></option>
                      <c:forEach var="equipment" items="${persist.equipments}">
                        <c:if test="${not equipment.disabled}">
                          <option value="${equipment.id}" ${equipment.id == param.equipmentId ? 'selected' : ''}>${equipment.name}</option>
                        </c:if>
                      </c:forEach>
                    </select>
                  </div>
                </div>
                <button type="submit" class="btn btn-default x-btn btn-shadow btn-shadow-default">查询</button>
              </form>
              <c:if test="${currentPrincipal.coursewareManager}">
                <div class="btn-group pull-right">
                  <a href="${ctx.host}/movements/create"  data-target="#create" data-toggle="modal" class="btn btn-default x-btn btn-shadow btn-shadow-default">
                    <i class="glyphicon glyphicon-plus"></i>&nbsp;&nbsp;新增动作
                  </a>
                </div>
              </c:if>
            </div>
            
          </div>
         
          <table class="table table-striped table-hover x-table action-table" style="margin-bottom:20px;">
            <thead>
              <tr>
                <th>序号</th>
                <th>名称</th>
                <th>类别</th>
                <th>器材</th>
                <th>组数</th>
                <th>每组动作次数</th>
                <th>最大重量</th>
                <th>计时</th>
                <th>缩略图</th>
                <th>动作要领</th>
                <th class="text-center">操作</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach var="movement" items="${movements}" varStatus="status">
                <tr>
                    <td>${status.index + 1}</td>
                    <td>${movement.name }</td>
                    <td>${movement.category.name}</td>
                    <td>${movement.equipment.name }</td>
                    <td>${movement.groupAmount}</td>
                    <td>${movement.movementNumber}</td>
                    <td>${movement.maxWeight}</td>
                    <td>${movement.time}</td>
                    <td><img alt="" src="${cloud.prod}/${movement.cover}-0.6" style="width: 50px; height: 50px;"></td>
                    <td style="max-width:160px;" class="ellipsis">${movement.summary}</td>
                    <td>
                      <a href="${ctx.host}/movements/${movement.id}">详情</a>&nbsp;&nbsp;
                      <c:if test="${currentPrincipal.coursewareManager}">
                        <a href="${ctx.host}/movements/${movement.id}/delete" data-target="#delete" data-toggle="modal">删除</a>
                      </c:if>
                    </td>
                  </tr>
                </c:forEach>
                  
            </tbody>
          </table>
          <jsp:include page="/WEB-INF/include/page.jsp">
            <jsp:param name="url" value="movements" />
            <jsp:param name="queryString" value="${queryString}" />
          </jsp:include>

        </div>
      </div>
    </div>
  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/courseware/movement/movement-list.js">
    <script type="text/javascript">
      require(['page/courseware/movement/movement-list'], function(page) {
        page.init({status: '${status}'})
      })
    </script>
  </d:resource>
  
</body>

</html>
